package com.tpyg.wallet.frame.utils;

import java.util.Map;
import java.util.WeakHashMap;

import com.tpyg.wallet.common.Const;


/**
 * 
 * @author Administrator
 *
 */
public class ResponseUtils {

	public static Object buildSuccessRes(Object data) {
		Map<String, Object> result = new WeakHashMap<String, Object>();
		result.put("status", Const.SUCCESS);
		if (data != null && !data.equals("")) {
			result.put("data", data);
		}
		return result;
	}

	public static Object buildSuccessRes(Map<String, Object> map, Object data) {
		Map<String, Object> result = new WeakHashMap<String, Object>();
		result.put("status", Const.SUCCESS);
		if (data != null && !data.equals("")) {
			result.put("data", data);
		}
		if (!map.isEmpty()) {
			result.putAll(map);
		}
		return result;
	}

	public static Object buildErrorRes(String state, String error) {
		Map<String, Object> result = new WeakHashMap<String, Object>();
		result.put("status", state);
		result.put("error", error);
		return result;
	}

}
